package com.xueyi.operations.controller.admin;

import com.xueyi.common.core.web.result.AjaxResult;
import com.xueyi.common.core.web.validate.V_A;
import com.xueyi.common.core.web.validate.V_E;
import com.xueyi.common.log.annotation.Log;
import com.xueyi.common.log.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import com.xueyi.operations.controller.base.BOpManufacturerController;
import com.xueyi.operations.domain.dto.OpManufacturerDto;
import com.xueyi.operations.domain.query.OpManufacturerQuery;
import io.swagger.v3.oas.annotations.Operation;
import com.xueyi.common.security.annotation.AdminAuth;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 * 资产管理 | 管理端 业务处理
 *
 * @author lwb
 */
@AdminAuth
@RestController
@RequestMapping("/admin/manufacturer")
public class AOpManufacturerController extends BOpManufacturerController {

    @Override
    @GetMapping("/list")
    @Operation(summary = "查询资产列表")
    @PreAuthorize("@ss.hasAuthority('RD:operations:manufacturer:list')")
    public AjaxResult list(OpManufacturerQuery opManufacturer) {
        return super.list(opManufacturer);
    }

    @Override
    @GetMapping(value = "/{id}")
    @Operation(summary = "查询资产详细")
    @PreAuthorize("@ss.hasAuthority('RD:operations:manufacturer:single')")
    public AjaxResult getInfo(@PathVariable Serializable id) {
        return super.getInfo(id);
    }

    @Override
    @PostMapping
    @Operation(summary = "资产新增")
    @PreAuthorize("@ss.hasAuthority('RD:operations:manufacturer:add')")
    @Log(title = "资产管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@Validated({V_A.class}) @RequestBody OpManufacturerDto opManufacturer) {
        return super.add(opManufacturer);
    }

    @Override
    @PutMapping
    @Operation(summary = "资产修改")
    @PreAuthorize("@ss.hasAuthority('RD:operations:manufacturer:edit')")
    @Log(title = "资产管理", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@Validated({V_E.class}) @RequestBody OpManufacturerDto opManufacturer) {
        return super.edit(opManufacturer);
    }

    @Override
    @PutMapping("/status")
    @Operation(summary = "资产修改状态")
    @PreAuthorize("@ss.hasAnyAuthority('RD:operations:manufacturer:edit', 'RD:operations:manufacturer:es')")
    @Log(title = "资产管理", businessType = BusinessType.UPDATE_STATUS)
    public AjaxResult editStatus(@RequestBody OpManufacturerDto opManufacturer) {
        return super.editStatus(opManufacturer);
    }

    @Override
    @DeleteMapping("/batch/{idList}")
    @Operation(summary = "资产批量删除")
    @PreAuthorize("@ss.hasAuthority('RD:operations:manufacturer:del')")
    @Log(title = "资产管理", businessType = BusinessType.DELETE)
    public AjaxResult batchRemove(@PathVariable List<Long> idList) {
        return super.batchRemove(idList);
    }
}
